package com.sa.user.controller;

/**
 * @author Architecture Station
 * @version 1.0
 * @website 
 */

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.util.SaResult;
import com.sa.user.api.dto.UserDTO;
import com.sa.user.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/users")
@RequiredArgsConstructor
public class UserController {

    @Autowired
    private final UserService userService;


    @PostMapping("/login")
    public SaResult login(@RequestBody UserDTO userDTO) {
        return userService.validateUser(userDTO);
    }

    @PostMapping("/test")
    public SaResult test() {
        return SaResult.ok("传递成功");
    }

    // 通过ID查询用户信息
    @SaCheckPermission("user:select")
//    @SaCheckPermission("user:query")
    @GetMapping("/{userId}")
    public SaResult getUserById(@PathVariable Long userId) {

        return SaResult.ok("访问成功" );
    }


}
